🎖️GitЯра🎖️
Node / meshtastic / Meshtastic-Android / files / core / network / src / jvmTest / kotlin / org / meshtastic / core / network / transport / ConnectionFailuresJvmTest.kt
Displaying Raw • Download
core/network/src/jvmTest/kotlin/org/meshtastic/core/network/transport/ConnectionFailuresJvmTest.kt 65a1f5ce4d0e4b8eafcd0bbfccafd41dc6ee888a (65a1f5ce) Text, 2.15 KB
T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.network.transport
Tff7b72import T7ee787java.io.EOFException
Tff7b72import T7ee787java.net.ConnectException
Tff7b72import T7ee787java.net.SocketException
Tff7b72import T7ee787java.net.UnknownHostException
Tff7b72import T7ee787java.nio.channels.UnresolvedAddressException
Tff7b72import T7ee787kotlin.test.Test
Tff7b72import T7ee787kotlin.test.assertFalse
Tff7b72import T7ee787kotlin.test.assertTrue
Tff7b72class T56d364ConnectionFailuresJvmTest Tb4b4b4{
Tf0883e@Test
Tff7b72fun Td2a8ff`an unresolvable hostname is an expected connection failure`Tb4b4b4(Tb4b4b4) Tb4b4b4{
T8b949e// Ktor throws this when the address will not resolve. It extends IllegalArgumentException, so before this
T8b949e// classification it escaped every catch(IOException) and was reported as an application error.
Te6edf3assertTrueTb4b4b4(Te6edf3UnresolvedAddressExceptionTb4b4b4(Tb4b4b4)Tb4b4b4.Te6edf3isExpectedConnectionFailureTb4b4b4(Tb4b4b4)Tb4b4b4)
Tb4b4b4}
Tf0883e@Test
Tff7b72fun Td2a8ff`ordinary unreachable-host failures are expected connection failures`Tb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3assertTrueTb4b4b4(Te6edf3ConnectExceptionTb4b4b4(Ta5d6ff"Ta5d6ffConnection refusedTa5d6ff"Tb4b4b4)Tb4b4b4.Te6edf3isExpectedConnectionFailureTb4b4b4(Tb4b4b4)Tb4b4b4)
Te6edf3assertTrueTb4b4b4(Te6edf3UnknownHostExceptionTb4b4b4(Ta5d6ff"Ta5d6ffno.such.hostTa5d6ff"Tb4b4b4)Tb4b4b4.Te6edf3isExpectedConnectionFailureTb4b4b4(Tb4b4b4)Tb4b4b4)
Te6edf3assertTrueTb4b4b4(Te6edf3SocketExceptionTb4b4b4(Ta5d6ff"Ta5d6ffConnection resetTa5d6ff"Tb4b4b4)Tb4b4b4.Te6edf3isExpectedConnectionFailureTb4b4b4(Tb4b4b4)Tb4b4b4)
Te6edf3assertTrueTb4b4b4(Te6edf3EOFExceptionTb4b4b4(Ta5d6ff"Ta5d6ffNot enough data availableTa5d6ff"Tb4b4b4)Tb4b4b4.Te6edf3isExpectedConnectionFailureTb4b4b4(Tb4b4b4)Tb4b4b4)
Tb4b4b4}
Tf0883e@Test
Tff7b72fun Td2a8ff`an unrelated IllegalArgumentException is still an error`Tb4b4b4(Tb4b4b4) Tb4b4b4{
T8b949e// Guards the classification from widening to every IllegalArgumentException.
Te6edf3assertFalseTb4b4b4(Te6edf3IllegalArgumentExceptionTb4b4b4(Ta5d6ff"Ta5d6ffbad portTa5d6ff"Tb4b4b4)Tb4b4b4.Te6edf3isExpectedConnectionFailureTb4b4b4(Tb4b4b4)Tb4b4b4)
Tb4b4b4}
Tb4b4b4}
Served by rngit 1.5.0 - Generated in 0.05s